//继承模板
{extend name="public/base"}


//CSS
{block name="style"}
<link rel="stylesheet" href="__ADMIN_STATIC__/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
{/block}

{block name="breadcrumb" title="当前位置"}
{/block}

//正文区域
{block name="body"}{//---------------------------------------------------------------------------}
<div class="page-container">
	

    <div class="cl pd-5 bg-1 bk-gray mb-10">
    <span class="l">

    <button onClick="list_add()" class="btn btn-primary radius" type="button">
    	<i class="Hui-iconfont">&#xe600;</i> 添加
    </button>

    <button onClick="list_batch_edit()" class="btn btn-secondary radius" type="button">
    	<i class="Hui-iconfont">&#xe647;</i> 修改
    </button>

    <button onClick="list_batch_del('{:url('del')}')" class="btn btn-danger  radius" type="button">
    	<i class="Hui-iconfont">&#xe6e2;</i> 删除
    </button>

    <span style=" line-height:30px; color:#CCCCCC; margin-left:10px;">双击可编辑数据</span>

    </span> 
    <span class="r ml-20">
        <button onClick="location.replace(location.href)" class="btn btn-success radius" type="button">
    	<i class="Hui-iconfont">&#xe68f;</i> 刷新
    	</button>
    </span>
    

    
    </div>
    <form class="Huiform" method="get" action="" id="listForm">
    <table class="table table-border table-bordered table-bg">
        <thead>
            <tr class="text-c">
                <th width="60">
                    <label><input type="checkbox" name="" value=""> ID</label>
                </th>
                <th >姓名</th>
                <th >登录账号</th>
                <th >在职状态</th>
                <th >性别</th>
                <th >部门 ( 岗位 ) </th>
                <th width="100">操作</th>
            </tr>
        </thead>
        <tbody>

{volist name="list|default=[]" id="vo"}
            <tr class="text-c">
                <td><label><input type="checkbox" value="{$vo.user_id}" name="id[]">{$vo.user_id}</label></td>

                <td>{$vo.username}</td>
                <td> {$vo.loginname}</td>
                <td>{$vo.status_text}  </td>
                <td>{$vo.sex_text}  </td>
                <td>{$vo.role} </td>

                <td>
                <button onClick="list_edit({$vo.user_id})" type="button" class="btn btn-secondary size-MINI radius">
			    	<i class="Hui-iconfont">&#xe647;</i> 修改
			    </button>

                </td>
{/volist}
            </tr>
        </tbody>
    </table>
    </form>
    <div class="pagination-wraper cl">
        {//$list->render()}
    </div>
</div>
{/block}
//-----------------------------------------------------------------------------------------------


<!--请在下方写此页面业务相关的脚本-->
//-----------------------------------------------------------------------------------------------
{block name="script"}
<script type="text/javascript">

var $listForm = $('#listForm'); // form#listForm
var edit_url ='{:url('edit')}';
var  del_url ='{:url('del')}';
/*添加*/
function list_add(){
	var title= '添加数据';
	var url = edit_url + ''; 
    layer_show_full(title,url);
}
/*行内 编辑*/
function list_edit(id){
	var title = '修改数据';
	var url = edit_url + '?&id=' + id ; 
    layer_show_full(title,url);
}
// function list_copy(id){
// 	var title = '修改数据,建立副本';
// 	var url = edit_url + '?dopost=copy&id=' + id ; 
//     layer_show_full(title,url);
// }

function list_batch_edit(){
    var id = $listForm.find('[name^=id]:checked ').val();
    if(!id){
    	layer.msg('请选择要操作的数据',{icon:1});return;
    }else{
    	list_edit(id);
    }
}

/*行内(tr)内点击删除*/
function list_del(obj,id){
    layer.confirm('确认要【删除】吗？',function(index){
        $.ajax({
            type: 'POST',
            url: del_url,
            data:{id:id},
            dataType: 'json',
            success: function(d){
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:1000});
            },
            error:function(d) {
                console.log(d.msg);
            },
        });     
    });
}
/* 批量删除 */
function list_batch_del(){

    if( $("[name^=id]:checked").length == 0  ){
        layer.msg('请选择要操作的数据',{icon:0});return false;
    };
    layer.confirm('确认要【删除】选中数据吗？',function(index){
        $.ajax({
            type: 'POST',
            url:del_url,
            data:$listForm.serialize() ,
            dataType: 'json',
            success: function(d){
                if(d.code == 1){
                    layer.msg('已删除!',{icon:1,time:1000});
                    $("[name^=id]:checked").parents("tr").remove();
                }else{
                    jBox.tip(d.msg,'success');
                }               
            },
            error:function(d) {
                console.log(d.msg);
            },
        });     
    });
}


$(function(){
	//双击修改
	$listForm.find('tbody tr').on('dblclick',function(){
		var id = $(this).find('[name^=id]').val();
		list_edit(id);
	});
});//$(function(){





</script>

<style>


	
</style>



{/block}{//---------------------------------------------------------------------------}